home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / termsorc.lha / Extras / Source / gtlayout-source.lha / LT_DeleteHandle.c < prev    next >
C/C++ Source or Header  |  1995-09-24  |  3KB  |  179 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. VOID __regargs
  10. LTP_DisposeGadgets(struct LayoutHandle *Handle)
  11. {
  12.     if(Handle -> List)
  13.     {
  14.         struct Gadget    *Gadget;
  15.         ObjectNode    *Node;
  16.  
  17.         if(Handle -> Window)
  18.             RemoveGList(Handle -> Window,Handle -> List,(UWORD)-1);
  19.  
  20.         Gadget = Handle -> List;
  21.  
  22.         if(Handle -> ExitFlush)
  23.         {
  24.             while(Gadget)
  25.             {
  26.                 if(GETOBJECT(Gadget,Node))
  27.                 {
  28.                     LTP_PutStorage(Node);
  29.  
  30.                     LTP_DeleteObjectNode(Handle,Node);
  31.                 }
  32.  
  33.                 Gadget = Gadget -> NextGadget;
  34.             }
  35.         }
  36.         else
  37.         {
  38.             while(Gadget)
  39.             {
  40.                 if(GETOBJECT(Gadget,Node))
  41.                     LTP_DeleteObjectNode(Handle,Node);
  42.  
  43.                 Gadget = Gadget -> NextGadget;
  44.             }
  45.         }
  46.  
  47.         FreeGadgets(Handle -> List);
  48.  
  49.         Handle -> List = NULL;
  50.     }
  51.  
  52. #ifdef DO_BOOPSI_KIND
  53.     if(Handle -> BOOPSIList)
  54.     {
  55.         struct Gadget *gadget = (struct Gadget *)Handle -> BOOPSIList,*next;
  56.         ObjectNode *Node;
  57.  
  58.         if(Handle -> Window)
  59.             RemoveGList(Handle -> Window,(struct Gadget *)Handle -> BOOPSIList,(UWORD)-1);
  60.  
  61.         while(gadget)
  62.         {
  63.             next = gadget -> NextGadget;
  64.  
  65.             if(GETOBJECT(gadget,Node))
  66.             {
  67.                 DisposeObject(gadget);
  68.  
  69.                 if(Node -> Type == BOOPSI_KIND)
  70.                 {
  71.                     if(Node -> Special . BOOPSI . ClassBase)
  72.                     {
  73.                         CloseLibrary(Node -> Special . BOOPSI . ClassBase);
  74.  
  75.                         Node -> Special . BOOPSI . ClassBase = NULL;
  76.                     }
  77.  
  78.                     if(Node -> Special . BOOPSI . ClassTags)
  79.                     {
  80.                         FreeTagItems(Node -> Special . BOOPSI . ClassTags);
  81.  
  82.                         Node -> Special . BOOPSI . ClassTags = NULL;
  83.                     }
  84.                 }
  85.  
  86.                 Node -> Host = NULL;
  87.             }
  88.  
  89.             gadget = next;
  90.         }
  91.  
  92.         Handle -> BOOPSIList = NULL;
  93.         Handle -> BOOPSIPrevious = NULL;
  94.     }
  95. #endif    /* DO_BOOPSI_KIND */
  96. }
  97.  
  98.  
  99. /*****************************************************************************/
  100.  
  101.  
  102. VOID LIBENT
  103. LT_DeleteHandle(REG(a0) LayoutHandle *Handle)
  104. {
  105.     if(Handle)
  106.     {
  107.         UnlockPubScreen(NULL,Handle -> PubScreen);
  108. #ifdef DO_CLONING
  109.         if(Handle -> CloneExtra)
  110.         {
  111.             if(Handle -> CloneExtra -> Screen)
  112.                 ScreenToBack(Handle -> CloneExtra -> Screen);
  113.         }
  114. #endif
  115.         LTP_DisposeGadgets(Handle);
  116.  
  117.         LT_UnlockWindow(Handle -> Parent);
  118.  
  119.         if(Handle -> Window)
  120.         {
  121.             LT_DeleteWindowLock(Handle -> Window);
  122.  
  123.             if(Handle -> MsgPort && Handle -> Window -> UserPort)
  124.             {
  125.                 struct IntuiMessage    *intuiMsg;
  126.                 struct Node        *next;
  127.  
  128.                 Forbid();
  129.  
  130.                 intuiMsg = (struct IntuiMessage *)Handle -> Window -> UserPort -> mp_MsgList . lh_Head;
  131.  
  132.                 while(next = intuiMsg -> ExecMessage . mn_Node . ln_Succ)
  133.                 {
  134.                     if(intuiMsg -> IDCMPWindow == Handle -> Window)
  135.                     {
  136.                         Remove(intuiMsg);
  137.  
  138.                         ReplyMsg(intuiMsg);
  139.                     }
  140.  
  141.                     intuiMsg = (struct IntuiMessage *)next;
  142.                 }
  143.  
  144.                 Handle -> Window -> UserPort = NULL;
  145.  
  146.                 ModifyIDCMP(Handle -> Window,NULL);
  147.  
  148.                 Permit();
  149.             }
  150.  
  151.             ClearMenuStrip(Handle -> Window);
  152.             CloseWindow(Handle -> Window);
  153.         }
  154.  
  155. #ifdef DO_MENUS
  156.         LT_DisposeMenu(Handle -> Menu);
  157. #endif    // DO_MENUS
  158.  
  159.         DisposeObject(Handle -> AmigaGlyph);
  160.         DisposeObject(Handle -> CheckGlyph);
  161.  
  162.         FreeScreenDrawInfo(Handle -> Screen,Handle -> DrawInfo);
  163.  
  164.         FreeVisualInfo(Handle -> VisualInfo);
  165.  
  166.         if(Handle -> RPort . Font && Handle -> CloseFont)
  167.             CloseFont(Handle -> RPort . Font);
  168. #ifdef DO_CLONING
  169.         if(Handle -> CloneExtra)
  170.         {
  171.             if(Handle -> CloneExtra -> Screen)
  172.                 CloseScreen(Handle -> CloneExtra -> Screen);
  173.         }
  174. #endif
  175.  
  176.         AsmDeletePool(Handle -> Pool,SysBase);
  177.     }
  178. }
  179.